﻿using UnityEngine;
using UnityEngine.UI;
public class BallShop : ShopItem {

//	public int index;
//	public Image img;

	public override void CheckStatus ()
	{
		base.CheckStatus ();
		PlayerPrefs.SetInt ("ball0", 1);
		if (ballLockStage == 1) {
			img.color = Color.white;
			costGroup.SetActive (false);
		} else {
			img.color = new Color32 (255, 255, 255, 155);
		}
		selectedImg.gameObject.SetActive (GameManager.CurrBall == index);
		if (GameManager.CurrBall == index)
			UiManager.tempBallSelect = selectedImg.gameObject;
	}

	public override void OnClickButton ()
	{
		base.OnClickButton ();
		if (UiManager.tempBallSelect != null && ballLockStage == 1)
			UiManager.tempBallSelect.SetActive (false);
		if (ballLockStage == 0) {
			if (GameStatistic.Coin > price) {
				ballLockStage = 1;
				UiManager.SetCoinText (true, -price);
			} else {
				print ("NOT ENOUGH COIN");
			}
		} else {
			GameManager.CurrBall = index;
		}
		CheckStatus ();
		AudioManager.PlayOneShoot (5);
	}
}
